require 'will_paginate/array'
class TagsController < ApplicationController
  layout 'user'
  def index
    @tags = Tag.where("name like '"+params[:pre]+"%'").order('use_time desc,name asc')
    render :partial => 'index'
  end
  def new
  end

  def create
  end

  def show
    @tag = Tag.find(params[:id])
    @searchs = Tag.find_by_sql('select d.id,d.projects as title,"demand" as s_type,d.created_at from demands as d where d.tag_id='+params[:id]+' union all select q.id,q.title,"question" as s_type,q.created_at from questions q where q.tag_id='+params[:id]+' order by created_at desc;').paginate   :page=> params[:page],:per_page=> 12
  end
end
